<template>
  <div>
    <!-- banner -->
    <div class="tag-banner banner">
      <h1 class="banner-title">标签</h1>
    </div>
    <!-- 标签列表 -->
    <v-card class="blog-container">
      <div class="tag-cloud-title">标签 - {{ count }}</div>
      <div class="tag-cloud">
        <span
                :style="{ 'font-size': Math.floor(Math.random() * 10) + 18 + 'px' }"
                v-for="item of tagList"
                :key="item.id"

        >
        <a @click="open(item)">{{ item.tag }}</a>
        </span>
      </div>
    </v-card>
  </div>
</template>

<script>
  import request from '../../utils/request'

export default {
  created() {
      let str=sessionStorage.getItem("user")
      this.form=JSON.parse(str)
    this.listTags();
      /*let id = this.$route.query
      request.get('/article/list/'+id).then(res=>{
          this.tagList = res.data
          this.count = res.data.length;

      });*/
  },
  data: function() {
    return {
        form:{},
      tagList: [],
      count: 0
    };
  },
  methods: {
      open(ids){
          let id=ids.id
          this.$router.push({
              path:'/tag/',
              query: {id:id}
          })

      },
    listTags() {
        request.get('/article/list/'+this.form.username).then(res=>{
            this.tagList = res.data
            this.count = res.data.length;

      });
    }
  },
    computed: {
        cover() {

            var cover = "";
                this.tagList.forEach(item => {
                    console.log(item)
                if (item.tag == "tag") {
                    cover = item.img;
                }
            });
            return "background: url(" + cover + ") center center / cover no-repeat";
        }
    }

};
</script>

<style scoped>
.tag-banner {
  background: url(https://static.talkxj.com/config/643f28683e1c59a80ccfc9cb19735a9c.jpg) center center /
    cover no-repeat;
  background-color: #49b1f5;
}
.tag-cloud-title {
  line-height: 2;
  font-size: 36px;
  text-align: center;
}
@media (max-width: 759px) {
  .tag-cloud-title {
    font-size: 25px;
  }
}
.tag-cloud {
  text-align: center;
}
.tag-cloud a {
  color: #616161;
  display: inline-block;
  text-decoration: none;
  padding: 0 8px;
  line-height: 2;
  transition: all 0.3s;
}
.tag-cloud a:hover {
  color: #03a9f4 !important;
  transform: scale(1.1);
}
</style>
